export function setupDarkMode() {
  // 检查用户之前是否设置了暗模式
  const savedTheme = localStorage.getItem('darkMode');
  if (savedTheme === 'true') {
    document.body.classList.add('dark-mode');
  }
  
  // 添加全局暗色模式样式
  const darkModeStyles = document.createElement('style');
  darkModeStyles.innerHTML = `
    body.dark-mode {
      --bg-primary: #121212;
      --bg-secondary: #1e1e1e;
      --bg-tertiary: #2d2d2d;
      --text-primary: #e0e0e0;
      --text-secondary: #b0b0b0;
      --text-tertiary: #8a8a8a;
      --card-bg: #1e1e1e;
      --card-border: #333;
      --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
      --header-gradient: linear-gradient(90deg, #193d88, #0c1220);
      --input-bg: #2d2d2d;
      --input-border: #444;
      --scrollbar-thumb: #444;
      --scrollbar-track: #222;
      --hover-bg: rgba(255, 255, 255, 0.05);
      
      color-scheme: dark;
      background-color: var(--bg-primary);
      color: var(--text-primary);
    }
    
    body.dark-mode .fixed-navbar {
      background: var(--header-gradient);
      box-shadow: 0 2px 15px rgba(0, 0, 0, 0.3);
    }
    
    body.dark-mode .hero-section {
      background-color: var(--bg-primary);
    }
    
    body.dark-mode .hero-bg-pattern {
      opacity: 0.1;
    }
    
    body.dark-mode .section-subtitle {
      color: var(--primary-color);
    }
    
    body.dark-mode .section-title {
      color: var(--text-primary);
    }
    
    body.dark-mode .expertise-card {
      background-color: var(--card-bg);
      box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
      border: 1px solid var(--card-border);
    }
    
    body.dark-mode .expertise-card h3 {
      color: var(--text-primary);
    }
    
    body.dark-mode .expertise-card p {
      color: var(--text-secondary);
    }
    
    body.dark-mode .expertise-icon {
      background: linear-gradient(45deg, var(--primary-color), #2160dd);
      box-shadow: 0 4px 15px rgba(33, 96, 221, 0.4);
    }
    
    body.dark-mode .featured-project-card {
      background-color: var(--card-bg);
      box-shadow: var(--card-shadow);
      border: 1px solid var(--card-border);
    }
    
    body.dark-mode .project-category {
      background-color: rgba(67, 97, 238, 0.2);
      color: #6b8aff;
    }
    
    body.dark-mode .project-title {
      color: var(--text-primary);
    }
    
    body.dark-mode .project-description {
      color: var(--text-secondary);
    }
    
    body.dark-mode .project-link {
      color: var(--primary-color);
    }
    
    body.dark-mode .contact-section {
      background: linear-gradient(135deg, #24408a, #251a53);
    }
    
    body.dark-mode .about-tabs .tab {
      background-color: var(--card-bg);
      color: var(--text-secondary);
    }
    
    body.dark-mode .about-tabs .tab.active {
      background-color: var(--primary-color);
      color: white;
    }
    
    body.dark-mode .skill-progress-bar {
      background-color: #444;
    }
    
    body.dark-mode .skill-progress {
      background: linear-gradient(45deg, var(--primary-color), #2160dd);
    }
    
    body.dark-mode .job-period {
      color: #6b8aff;
    }
    
    body.dark-mode .stat-number {
      color: var(--primary-color);
    }
    
    body.dark-mode .stat-label {
      color: var(--text-secondary);
    }
    
    body.dark-mode input,
    body.dark-mode textarea,
    body.dark-mode select {
      background-color: var(--input-bg);
      border-color: var(--input-border);
      color: var(--text-primary);
    }
    
    body.dark-mode ::-webkit-scrollbar {
      width: 10px;
    }
    
    body.dark-mode ::-webkit-scrollbar-track {
      background: var(--scrollbar-track);
    }
    
    body.dark-mode ::-webkit-scrollbar-thumb {
      background: var(--scrollbar-thumb);
      border-radius: 5px;
    }
    
    body.dark-mode .scroll-dot {
      background-color: rgba(255, 255, 255, 0.2);
    }
    
    body.dark-mode .scroll-dot.active {
      background-color: var(--primary-color);
      box-shadow: 0 0 10px rgba(67, 97, 238, 0.7);
    }
    
    body.dark-mode .lang-dropdown {
      background-color: var(--card-bg);
      box-shadow: 0 5px 25px rgba(0, 0, 0, 0.3);
      border: 1px solid var(--card-border);
    }
    
    body.dark-mode .lang-option {
      color: var(--text-primary);
    }
    
    body.dark-mode .lang-option:hover, 
    body.dark-mode .lang-option.active {
      background-color: var(--hover-bg);
    }
    
    /* 动画和过渡效果 */
    body.dark-mode,
    body.dark-mode * {
      transition: background-color 0.3s, color 0.3s, border-color 0.3s, box-shadow 0.3s;
    }
  `;
  
  document.head.appendChild(darkModeStyles);
} 